<include file="public@header"/>
</head>
<body>
<div class="layui-fluid js-check-wrap">
    <div class="layui-card">
        <div class="layui-card-header">
            <h3>{:lang('REPAIR_ADMINARTICLE_INDEX')}</h3>
        </div>
        <div class="layui-card-body">
            <form class="form-search layui-form layui-form-item clearfix" action="{:url('AdminArticle/index')}">
                <div class="layui-col-md11 layui-col-sm10">
                    <div class="layui-inline">
                        <input type="text" class="layui-input" name="keyword" 
                           value="{$keyword|default=''}" placeholder="{:lang('PLEASE_ENTER_KEYWORD')}">
                    </div>
                    <div class="layui-inline">
                        <select class="layui-input" name="category" >
                            <option value=''>{:lang('PLEASE_SELECTED_CATEGORY')}</option>
                            {$category_tree|default=''}
                        </select>
                    </div>
                    <!-- 审核状态 -->
                    <!-- <select class="layui-input" name="post_status" style="width: auto;">
                        <option value="0" >{:lang('PLEASE_SELECTED_AUDIT')}</option>
                        <option value="1" <eq name="filter.post_status" value="1">selected</eq> >{:lang('WAIT_AUDIT')}</option>
                        <option value="99" <eq name="filter.post_status" value="99">selected</eq> >{:lang('PASS_AUDIT')}</option>
                        <option value="-1" <eq name="filter.post_status" value="-1">selected</eq> >{:lang('NOT_PASS_AUDIT')}</option>
                    </select> -->
                    
                    <div class="layui-inline">
                        <label class="layui-form-label">{:lang('TIME')}:</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input js-layui-date" name="start_time"
                                   value="{$start_time|default=''}"
                                   style="width: 100px;" autocomplete="off">
                        </div>
                        <div class="layui-form-mid">-</div>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input js-layui-date" name="end_time"
                                   value="{$end_time|default=''}"
                                   style="width: 100px;" autocomplete="off">
                        </div>                    
                    </div>

                    <!-- 列表排序 -->
                    <input type="hidden" name="sort_by" value="{$filter.sort_by}">
                    <input type="hidden" name="list_order" value="{$filter.list_order}">
                    <!-- 每页数量 -->
                    <input type="hidden" name="page_size" value="{$filter.page_size}">
    
                    <div class="layui-inline">
                        <input type="submit" class="layui-btn layui-btn-normal" value="{:lang('SEARCH')}"/>
                    </div>
                    <!-- <a class="layui-btn layui-btn-danger layui-btn-sm" href="{:url('AdminArticle/index')}">清空</a> -->


                    <!-- <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/export')">
                        <div class="layui-inline">
                            <a class="layui-btn layui-btn-danger" href="{:url('AdminArticle/export',array('start_time'=>$start_time,'end_time'=>$end_time,'keyword'=>$keyword,'category'=>$category))}" >导出点击量统计</a>
                        </div>
                    </if> -->
                </div>
                <div class="layui-col-md1 layui-col-sm2">
                    <a class="layui-btn layui-btn-normal fr" href="{:url('AdminArticle/add',array('category'=>$category))}">{:lang('PORTAL_ADMINREPAIR_ADD')}</a>
                </div>
            </form>
        </div>
        <form class="js-ajax-form" action="" method="post">
            <table class="layui-table" lay-skin="line">
                <thead>
                <tr>
                    <th width="" class="text-center">
                        <div class="custom-checkbox">
                            <input type="checkbox" id="checkall" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                            <label for="checkall"></label>
                        </div>
                    </th>
                    <!-- 排序 -->
                    <if condition="in_array('list_order',$list_item)">
                        <th class="text-a-c" width="55"><a href="javascript:list_sort('list_order');">{:lang('SORT')}</a>{$sort_list_order}</th>
                    </if>
                    <!-- <th width="50"><a href="javascript:list_sort('id');">ID</a>{$sort_id}</th> -->
                    <!-- 标题 -->
                        <if condition="in_array('post_title',$list_item)">
                            <th><a href="javascript:list_sort('post_title');">{:lang('title')}</a>{$sort_post_title}</th>
                        </if>
                    <!-- 分类 -->
                        <if condition="in_array('category',$list_item)">
                            <th style="width:10%;">{:lang('category')}</th>
                        </if>
                    <!-- 作者 -->
                        <if condition="in_array('user_login',$list_item)">
                            <th width="65"><a href="javascript:list_sort('user_login');">{:lang('author')}</a>{$sort_user_login}</th>
                        </if>
                    <!-- 点击量 -->
                        <if condition="in_array('post_hits',$list_item)">
                            <th width="55"><a href="javascript:list_sort('post_hits');">点击量</a>{$sort_post_hits}</th>
                        </if>
                    <!-- <th width="65">评论量</th> -->
        
                    <!-- 关键字 -->
                        <!-- <if condition="in_array('post_keywords',$list_item)">
                            <th width="">关键字</th>
                        </if> -->
                    <!-- 来源 -->
                        <if condition="in_array('post_source',$list_item)">
                            <th width="">{:lang('SOURCE')}</th>
                        </if>
                    <!-- 摘要 -->
                        <if condition="in_array('post_excerpt',$list_item)">
                            <th width="">{:lang('EXCERPT')}</th>
                        </if>
                    <!-- 图片 -->
                        <if condition="in_array('thumbnail',$list_item)">
                            <th width="">{:lang('PICTURE')}</th>
                        </if>
                    <!-- 显示/隐藏 -->
                        <if condition="in_array('is_show',$list_item)">
                            <th>{:lang('DISPLAY_HIDE')}</th>
                        </if>
                    <!-- 是否置顶 -->
                        <if condition="in_array('is_top',$list_item)">
                            <th>{:lang('IS_TOP')}</th>
                        </if>
                    <!-- 是否推荐 -->
                        <if condition="in_array('recommended',$list_item)">
                            <th>{:lang('RECOMMENDED')}</th>
                        </if>
                    <!-- 维修状态 -->
                        <if condition="in_array('repair_status',$list_item)">
                            <th>维修状态</th>
                        </if>
                    <!-- 评论状态 -->
                        <if condition="in_array('post_evaluate',$list_item)">
                            <th width="70">评论状态</th>
                        </if>
                    <!-- 审核状态 -->
                        <if condition="in_array('post_status',$list_item)">
                            <th width="70">{:lang('POST_STATUS')}</th>
                        </if>
                    <!-- 发布时间 -->
                        <if condition="in_array('published_time',$list_item)">
                            <th width="80"><a href="javascript:list_sort('published_time');">{:lang('ADD_TIME')}</a>{$sort_published_time}</th>
                        </if>
                    <!-- 更新时间 -->
                        <if condition="in_array('update_time',$list_item)">
                            <th width="80"><a href="javascript:list_sort('update_time');">{:lang('UPDATE_TIME')}</a>{$sort_update_time}</th>
                        </if>
                    <th width="200">{:lang('ACTIONS')}</th>
                </tr>
                </thead>

                <foreach name="articles" item="vo">
                    <tr>
                        <td class="text-center">
                            <!-- <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                                   value="{$vo.id}" title="ID:{$vo.id}"> -->
                            <div class="custom-checkbox">
                                <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" id="chk_{$vo.id}"
                                   value="{$vo.id}" title="ID:{$vo.id}">
                                <label for="chk_{$vo.id}"></label>
                            </div>
                        </td>
                        <!-- 排序 -->
                        <if condition="in_array('list_order',$list_item)">
                            <td>
                                <input name="list_orders[{$vo.post_category_id}]" class="input-order" type="text"
                                       value="{$vo.list_order}">
                            </td>
                        </if>

                        <!-- <td><b>{$vo.id}</b></td> -->

                        <!-- 标题 -->
                        <if condition="in_array('post_title',$list_item)">
                            <td>
                                <notempty name="category">
                                    <a href="javascript:"
                                       target="_blank">{$vo.post_title}</a>
                                    <else/>
                                    <a href="javascript:"
                                       target="_blank">{$vo.post_title}</a>
                                </notempty>
                            </td>
                        </if>
                        <!-- 分类 -->
                        <if condition="in_array('category',$list_item)">
                            <td>
                                <foreach name="vo.categories" item="voo">
                                    <!-- <span class="label label-default"> -->
                                        <a href="{:cmf_url('repair/List/index',array('id'=>$voo['id']))}" target="_blank"
                                        >{$voo.name}</a>
                                    <!-- </span>&nbsp; -->
                                </foreach>
                            </td>
                        </if>

                        <!-- 作者 -->
                        <if condition="in_array('user_login',$list_item)">
                            <td>{$vo.user_login}</td>
                        </if>

                        <!-- 点击量 -->
                        <if condition="in_array('post_hits',$list_item)">
                            <td>{$vo.post_hits|default=0}</td>
                        </if>
                        <!-- <td>
                            <notempty name="vo.comment_count">
                                {$vo.comment_count|default='0'}
                                <a href="javascript:parent.openIframeDialog('{:url('comment/commentadmin/index',array('post_id'=>$vo['id']))}','评论列表')">{$vo.comment_count}</a>
                                <else/>
                                {$vo.comment_count|default='0'}
                            </notempty>
                        </td> -->

                        <!-- 关键字 -->
                        <!-- <if condition="in_array('post_keywords',$list_item)">
                            <td>
                            <notempty name="vo.post_keywords">
                                <i class="fa fa-check fa-fw"></i>
                                <else/>
                                <i class="fa fa-close fa-fw c-danger"></i>
                            </notempty>
                            </td>
                        </if> -->
                        <!-- 来源 -->
                        <if condition="in_array('post_source',$list_item)">
                            <td>
                            <notempty name="vo.post_source">
                                <i class="fa fa-check fa-fw"></i>
                                <else/>
                                <i class="fa fa-close fa-fw c-danger"></i>
                            </notempty>
                            </td>
                        </if>
                        <!-- 摘要 -->
                        <if condition="in_array('post_excerpt',$list_item)">
                            <td>
                            <notempty name="vo.post_excerpt">
                                <i class="fa fa-check fa-fw"></i>
                                <else/>
                                <i class="fa fa-close fa-fw c-danger"></i>
                            </notempty>
                            </td>
                        </if>
                        <!-- 缩略图 -->
                        <if condition="in_array('thumbnail',$list_item)">
                            <td>
                            <notempty name="vo.more.thumbnail">
                                <a href="javascript:parent.imagePreviewDialog('{:cmf_get_image_preview_url($vo.more.thumbnail)}');">
                                    <i class="fa fa-photo fa-fw"></i>
                                </a>
                            </notempty>
                            </td>
                        </if>

                        <!-- 显示/隐藏 -->
                        <if condition="in_array('is_show',$list_item)">
                            <td>
                                <notempty name="vo.is_show">
                                    <span class="layui-btn layui-btn-normal layui-btn-xs">{:lang('DISPLAY')}</span>
                                    <else/>
                                    <span class="layui-btn layui-btn-xs layui-btn-danger">{:lang('HIDE')}</span>
                                </notempty>
                            </td>
                        </if>
                        <!-- 是否置顶 -->
                        <if condition="in_array('is_top',$list_item)">
                            <td>
                                <notempty name="vo.is_top">
                                    <span class="layui-btn layui-btn-xs layui-btn-danger">{:lang('YES')}</span>
                                    <else/>
                                    <span class="layui-btn layui-btn-normal layui-btn-xs">{:lang('NO')}</span>
                                </notempty>
                            </td>
                        </if>
                        <!-- 是否推荐 -->
                        <if condition="in_array('recommended',$list_item)">
                            <td>
                                <notempty name="vo.recommended">
                                    <span class="layui-btn layui-btn-xs layui-btn-danger">{:lang('YES')}</span>
                                    <else/>
                                    <span class="layui-btn layui-btn-normal layui-btn-xs">{:lang('NO')}</span>
                                </notempty>
                            </td>
                        </if>
                        <!-- 维修状态 -->
                        <if condition="in_array('repair_status',$list_item)">
                            <td>
                                <if condition="$vo.repair_status eq 0">
                                    <span class="layui-btn layui-btn-xs layui-btn-danger">派单中</span>
                                <elseif condition="$vo.repair_status eq 1">
                                    <span class="layui-btn layui-btn-xs layui-btn-xs">已派单</span>
                                <elseif condition="$vo.repair_status eq 2">
                                    <span class="layui-btn layui-btn-xs layui-btn-danger">维修中</span>
                                <elseif condition="$vo.repair_status eq 3">
                                    <span class="layui-btn layui-btn-warm layui-btn-xs">已完成</span>
                                <elseif condition="$vo.repair_status eq 4">
                                    <span class="layui-btn layui-btn-xs layui-btn-danger">结单申请</span>
                                <elseif condition="$vo.repair_status eq 5">
                                    <span class="layui-btn layui-btn-normal layui-btn-xs">已拒绝</span>
                                </if>
                            </td>
                        </if>
                        <!-- 评论状态 -->
                        <if condition="in_array('post_evaluate',$list_item)">
                            <td>
                                <if condition="$vo.evaluate_status eq 0">
                                    <span class="layui-btn layui-btn-xs layui-btn-danger ">未评价</span>
                                <elseif condition="$vo.evaluate_status eq 1">
                                    <span class="layui-btn layui-btn-xs layui-btn-normal">满意</span>
                                <elseif condition="$vo.evaluate_status eq 2">
                                    <span class="layui-btn layui-btn-xs layui-btn-normal">基本满意</span>
                                <elseif condition="$vo.evaluate_status eq 3">
                                    <span class="layui-btn layui-btn-xs layui-btn-normal">不满意</span>
                                </if>
                            </td>
                        </if>
                        <!-- 审核状态 -->
                        <if condition="in_array('post_status',$list_item)">
                        <td align="center">
                            <if condition="$vo.post_status eq 99">
                                <a data-toggle="tooltip" title="{:lang('PASS_AUDIT')}"><i class="fa fa-check"></i></a>
                            <elseif condition="$vo.post_status eq -1">
                                <a data-toggle="tooltip" title="{:lang('NOT_PASS_AUDIT')}"><i class="fa fa-close text-danger"></i></a>
                            <else/>
                                <a style="font-size:16px;" data-toggle="tooltip" title="{:lang('WAIT_AUDIT')}"><i class="fa fa-spinner text-warning fa-spin"></i></a>
                            </if>
                        </td>
                        </if>

                        <!-- 发布时间 -->
                        <if condition="in_array('published_time',$list_item)">
                        <td>
                            <empty name="vo.published_time">
                                -
                                <else/>
                                {:date('Y-m-d H:i:s',$vo['published_time'])}
                            </empty>
                        </td>
                        </if>
                        <!-- 更新时间 -->
                        <if condition="in_array('update_time',$list_item)">
                        <td>
                            <notempty name="vo.update_time">
                                {:date('Y-m-d H:i:s',$vo['update_time'])}
                            </notempty>
                        </td>
                        </if>

                        <td>
                            <if condition="$vo['is_edit']">
                                <a href="{:url('AdminArticle/edit',array('id'=>$vo['id']))}" class="layui-btn layui-btn-xs">{:lang('EDIT')}</a>
                            </if>
                            <if condition="$vo['is_delete']">
                                <a href="{:url('AdminArticle/delete',array('id'=>$vo['id']))}" class="js-ajax-delete layui-btn layui-btn-danger layui-btn-xs">{:lang('DELETE')}</a>
                            </if>
                             <if condition="$vo.repair_status eq 3">
                                <a href="{:url('AdminArticle/edit_apply',array('id'=>$vo['id']))}" class="layui-btn layui-btn-xs">已完成</a>
                            </if>
                            <if condition="$vo.repair_status eq 4">
                                <a href="{:url('AdminArticle/edit_apply',array('id'=>$vo['id']))}" class="layui-btn layui-btn-xs">结单申请审批</a>
                            </if>
                            <if condition="$vo.repair_status eq 5">
                                <a href="{:url('AdminArticle/edit_apply',array('id'=>$vo['id']))}" class="layui-btn layui-btn-xs">已拒绝</a>
                            </if>
                        </td>
                    </tr>
                </foreach>
            </table>
            <div class="pagination-row clearfix">
                <div class="layui-col-sm5 layui-col-md6 text-left-sm">
                    <!-- 显示条数 -->
                    <div class="btn-group dropup marginTB-xs">
                        <button type="button" class="layui-btn layui-btn-primary  layui-btn-md dropdown-toggle" data-toggle="dropdown">
                            显示条数 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu" role="menu">
                            <li><a href="javascript:setPageSize(10);">10</a></li>
                            <li><a href="javascript:setPageSize(20);">20</a></li>
                            <li><a href="javascript:setPageSize(30);">30</a></li>
                            <li><a href="javascript:setPageSize(50);">50</a></li>
                            <li><a href="javascript:setPageSize(80);">80</a></li>
                            <li><a href="javascript:setPageSize(100);">100</a></li>
                        </ul>
                    </div>

                    <!-- <a class="layui-btn layui-btn-md" data-table-name="repair_post" href="javascript:;" onclick="setListItem(this)">列表项</a> -->

                    <!--批量操作-->
                    <!-- <div class="btn-group dropup marginTB-xs" id="edit_more">
                        <button type="button" class="layui-btn layui-btn-normal layui-btn-md dropdown-toggle" data-toggle="dropdown">
                            批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/openshow')">
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                            data-action="{:url('AdminArticle/openshow',array('yes'=>1))}" data-subcheck="true">{:lang('MARKUP_DISPLAY')}
                                    </button>
                                </li>
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                        data-action="{:url('AdminArticle/openshow',array('no'=>1))}" data-subcheck="true">{:lang('MARKUP_HIDE')}
                                    </button>
                                </li>
                                <li class="divider"></li>
                            </if>

                            <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/top')">
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                            data-action="{:url('AdminArticle/top',array('yes'=>1))}" data-subcheck="true">{:lang('MARKUP_TOP')}
                                    </button>
                                </li>
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                            data-action="{:url('AdminArticle/top',array('no'=>1))}" data-subcheck="true">{:lang('CANCEL_TOP')}
                                    </button>
                                </li>
                                <li class="divider"></li>
                            </if>

                            <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/recommend')">
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                            data-action="{:url('AdminArticle/recommend',array('yes'=>1))}" data-subcheck="true">{:lang('MARKUP_RECOMMEND')}
                                    </button>
                                </li>
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                            data-action="{:url('AdminArticle/recommend',array('no'=>1))}" data-subcheck="true">{:lang('CANCEL_RECOMMEND')}
                                    </button>
                                </li>
                                <li class="divider"></li>
                            </if>

                            <notempty name="category">
                                <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/move')">
                                    <li><button class="js-articles-move" type="button">{:lang('BATCH_MOVE')}</button></li>
                                    <li class="divider"></li>
                                </if>
                            </notempty>

                            <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/copy')">
                                <li><button class="js-articles-copy" type="button">{:lang('BATCH_COPY')}</button></li>
                            </if>
                        </ul>
                    </div> -->

                    <!-- 排序 -->
                    <if condition="cmf_auth_check(cmf_get_current_admin_id(), 'repair/adminarticle/listorder')">
                        <if condition="in_array('list_order',$list_item)">
                            <button class="layui-btn layui-btn-warm layui-btn-md js-ajax-submit" type="submit"
                                    data-action="{:url('AdminArticle/listOrder')}">{:lang('SAVE_SORT')}</button>
                        </if>
                    </if>

                    <!-- 删除选中项 -->
                    <div class="btn-group">
                        <button class="layui-btn layui-btn-danger layui-btn-md js-ajax-submit" type="submit"
                                data-action="{:url('AdminArticle/delete')}" data-subcheck="true" data-msg="您确定删除吗？">
                            {:lang('DELETE_SELECTED')}
                        </button>
                    </div>
                </div>
                <div class="pages">{$page|default=''}</div>
            </div>
        </form>
    </div>
</div>
<include file="public@footer"/>
<script>
    function checkAdd(){
        var category = {$category};
        if( category==0 ){
            art.dialog.through({
                id: 'error',
                icon: 'error',
                content: '请先选择分类，并进行搜索！',
                cancelVal: '关闭',
                cancel: true
            });
            return;
        }else{
            var href = "{:url('AdminArticle/add',array('category'=>$category))}";
            window.location.href = href;
        }
    }
    
    function reloadPage(win) {
        win.location.reload();
    }

    $(function () {
        setCookie("refersh_time", 0);
        Wind.use('ajaxForm', 'artDialog', 'iframeTools','layer', function () {
            //批量复制
            $('.js-articles-copy').click(function (e) {
                var ids = [];
                $("input[name='ids[]']").each(function () {
                    if ($(this).is(':checked')) {
                        ids.push($(this).val());
                    }
                });

                if (ids.length == 0) {
                    // art.dialog.through({
                    //     id: 'error',
                    //     icon: 'error',
                    //     content: '您没有勾选信息，无法进行操作！',
                    //     cancelVal: '关闭',
                    //     cancel: true
                    // });
                    layer.msg('请选择您要操作的数据！');

                    return false;
                }

                ids = ids.join(',');

                layer.open({
                    type: 2,
                    title: "批量复制",  
                    content: GV.ROOT + "repair/admin_article/copy?&ids=" + ids
                });

                // art.dialog.open(GV.ROOT + "repair/admin_article/copy?&ids=" + ids, {
                //     title: "批量复制",
                //     width: "300px"
                // });
            });

            //批量移动
            $('.js-articles-move').click(function (e) {
                var ids = [];
                $("input[name='ids[]']").each(function () {
                    if ($(this).is(':checked')) {
                        ids.push($(this).val());
                    }
                });

                if (ids.length == 0) {
                    // art.dialog.through({
                    //     id: 'error',
                    //     icon: 'error',
                    //     content: '您没有勾选信息，无法进行操作！',
                    //     cancelVal: '关闭',
                    //     cancel: true
                    // });
                    layer.msg('请选择您要操作的数据！');
                    return false;
                }

                ids = ids.join(',');
                // art.dialog.open(GV.ROOT + "repair/admin_article/move?old_cat_id={$category|default=0}&ids=" + ids, {
                //     title: "批量移动",
                //     width: "300px"
                // });

                layer.open({
                    type: 2,
                    title: "批量移动",  
                    content: GV.ROOT + "repair/admin_article/move?old_cat_id={$category|default=0}&ids=" + ids
                });
            });
        });
    });
</script>
